#ifndef BUILDING_H
#define BUILDING_H

#include <QGLWidget>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <QKeyEvent>
#include <QMouseEvent>
#include <camera.h>
#include <xmlparser.h>
#include <QImage>

#if WIN32
#pragma comment (lib, "Opengl32.lib")
#pragma comment (lib, "glu32.lib")
#endif
class Building:public QGLWidget
{
    Q_OBJECT
public:
    Building(QWidget *parent=0);
    ~Building();
    void startPicking();
    void processHits(GLint hits, GLuint buffer[]);
    void stopPicking();
    void processHits2(GLint hits, GLuint buffer[]);
protected:
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
    void LoadGLTextures(QString fileName);
    virtual GLuint makeObject();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void moveEvent(QMoveEvent * event);
    void mouseReleaseEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);
    void keyPressEvent(QKeyEvent * e);
    bool eventFilter(QObject *, QEvent *);
    void pickColor(int cursorX, int cursorY);
    void pickObject(int cursorX, int cursorY);
private:
    void drawRectangle(GLfloat b, GLfloat h, GLfloat d);
    QString clickid;
    GLuint object;
    GLuint *textureIDs;
    GLfloat rotateX;
    GLfloat translateX;
    GLfloat translateY;
    GLfloat translateZ;
    CCamera camera;
    XMLParser xml;
    int x,y;
    int xdegree;
    bool frame;
    GLenum mode;
    GLuint selectBuf[512];
    GLint hits;
    int selectmode;
    int cursorX;
    int cursorY;
    int selected;
    float ratio;
    bool light1;
    bool light2;
    bool globallight;
};

#endif // BUILDING_H
